<%--
  Created by IntelliJ IDEA.
  User: 15041
  Date: 2020/12/18
  Time: 17:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/axios-0.18.0.js"></script>
    <script src="js/vue-v2.6.11.js"></script>
</head>
<body>
<div id="app">
    <button @click="testGet">异步请求Get</button>
    <button @click="testPost">异步请求Post 返回值类型String</button>
    <button @click="testPost2">异步请求Post 返回值类型为list集合</button>
</div>
<script type="text/javascript">
    new Vue({
        el:"#app",
        data:{

        },
        methods:{
            testGet(){
                axios.get("/user/testGet.do?id=1").then((resp)=>{
                    console.log(resp);
                }).catch((err)=>{
                    console.log(err);
                });
            },
            testPost(){
                var param = {
                    id:1,
                    username:"张三",
                    age:20
                };
                axios.post("/user/testPost.do",param).then((resp)=>{
                    console.log(resp);
                }).catch((err)=>{
                    console.log(err);
                });
            },
            testPost2(){
                var param = {
                    id:5,
                    username:"田七",
                    age: 19
                };
                axios.post("/user/testPost2.do",param).then((resp)=>{
                    console.log(resp);
                }).catch((err)=>{
                    console.log(err);
                });
            }
        }
    });
</script>

</body>
</html>
